﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CDT_CSDLNC
{
    public partial class ucXacNhanHangMua : UserControl
    {
        public ucXacNhanHangMua()
        {
            InitializeComponent();
        }

        public string maTinBan;
        public string maTaiKhoanMua;
        public int soLuongMua;
        public int donGia;
        public string tenSanPham;
        public int phiVanChuyen;
        public int thanhTien;

        private void XuLyKichBan()
        {
            frmMain main = (frmMain)this.ParentForm;
            int flag = main.flag;
            switch (flag)
            {
                case 1:
                    main.kb1_buoc = 6;
                    main.KichBan1();
                    break;
                case 2:
                    main.kb2_buoc = 7;
                    main.KichBan2();
                    break;
                case 3:
                    main.kb3_buoc = 6;
                    main.KichBan3();
                    break;
                case 4:
                    main.kb4_buoc = 6;
                    main.KichBan4();
                    break;
            }
        }

        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            XuLyKichBan();
        }

        private void ucXacNhanHangMua_Load(object sender, EventArgs e)
        {
            thanhTien = phiVanChuyen + soLuongMua * donGia;
            dgvDanhSachSanPham.Rows.Add(maTinBan, tenSanPham, soLuongMua, donGia, soLuongMua * donGia);
            lbTongTien.Text = (soLuongMua * donGia).ToString();
            lbTongPhiVanChuyen.Text = (soLuongMua * phiVanChuyen).ToString();
            lbTongThanhToan.Text = (soLuongMua * phiVanChuyen + soLuongMua * donGia).ToString();
        }
    }
}
